﻿# coding=UTF-8
from appengine_django.models import BaseModel
from google.appengine.ext import db
    
class UserFile(db.Model):
    name = db.StringProperty()
    mimetype = db.StringProperty()
    comment = db.StringProperty()
    size = db.IntegerProperty()
    author = db.UserProperty()
    creationDate = db.DateTimeProperty(auto_now_add=True)

    def delete(self):
        bin = self.filebin_set.get()
        if bin:
            bin.delete()
        super(UserFile, self).delete()

class FileBin(db.Model):
    userfile = db.ReferenceProperty(UserFile)
    bin = db.BlobProperty()
    
